<?php

/**
 * CV actions.
 *
 * @package    MonSite
 * @subpackage CV
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class CVActions extends sfActions {

    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function preExecute() {
        // The code inserted here is executed at the beginning of each action call
        // echo "haha";
    }

    public function postExecute() {

        //echo "hummm";
    }

    public function executeIndex(sfWebRequest $request) {
        //$this->forward('default', 'module');
    }
    
    public function executeMongo(sfWebRequest $request){
        
    }
  
    public function executeReference(sfWebRequest $request){
        
    }

    public function executeTable(sfWebRequest $request) {

        $url = $request->getPathInfo();
        $Complete = $request->getUri();

//        var_dump($request->getMethod());
//        var_dump($request->getUri());
//        var_dump($request->getReferer());
//        var_dump($request->getHost());
//        var_dump($request->getLanguages());
//        var_dump($request->getCharsets());
//        var_dump($request->getHttpHeader());
//        var_dump($request->getGetParameter());
//        var_dump($request->getPostParameter());
//        var_dump($request->getUrlParameter());
//        var_dump($request->getRemoteAddress());
        
//        var_dump($url);
//        var_dump($Complete);
//        $path = parse_url($Complete);
//
//        echo($path['path'] . "  --  ");
//
//        echo($this->getModuleName() . " and ");
//        echo($this->getActionName());
        $con = new Mongo();
        $db = $con->admin;
        $coll = $db->haha;
        $obj = array("wiz"=>"rly");
        $coll->insert($obj);
        $obj = array("wiz"=>"gaga","lala"=>2);
        $coll->insert($obj);
        $cursor = $coll->find();
        //var_dump($cursor);
        echo "Here mongo:";
        foreach ($cursor as $obj){
            echo $obj["wiz"]."\n";
        }
        echo "Ici ending!";


//        $this->author = Doctrine::getTable('Author')->find('1');
//        $this->forward404If(!$this->author);
//
        $query = Doctrine::getTable('Author')
                ->createQuery('c')
                ->where('c.sex LIKE ?', '%E%')
                ->orWhere('c.sex = ?', 'M')
                ->orderBy('c.age DESC')
                ->limit(3);
        $this->news = $query->execute();


        $this->form = new sfForm();
        $this->form->setWidgets(array(
            'hey' => new sfWidgetFormInputText(),
            'yoyo' => new sfWidgetFormInputText(array('default' => '50475@supinfo.com'), array('id' => 'Funyyyyy')),
            'heyman' => new sfWidgetFormChoice(array('choices' => array('humm', 'fck', 'wtf'))),
            'country' => new sfWidgetFormChoice(array(
                'choices' => array('' => 'Select from the list', 'us' => 'USA', 'ca' => 'Canada', 'uk' => 'UK', 'other'),
                'default' => ''
            )),
            'languages' => new sfWidgetFormChoice(array(
                'multiple' => 'true',
                'choices' => array('en' => 'English', 'fr' => 'French', 'other'),
                'default' => array('en', 0)
            )),
            'interests' => new sfWidgetFormChoice(array(
                'multiple' => 'true',
                'expanded' => true,
                'choices' => array('Programming', 'Other')
            )),
            'gender' => new sfWidgetFormChoice(array(
                'expanded' => true,
                'choices' => array('m' => 'Male', 'f' => 'Female'),
                'default' => 'f'
            ))
        ));
        $this->form->getWidgetSchema()->setIdFormat('hummm_form_%s');
        $this->form->getWidgetSchema()->setNameFormat('WTF_form_%s');

        $this->authorform = new AuthorForm();
        $this->form = new AuthorForm();

        if ($request->isMethod('POST')) {

            $para = $request->getParameter($this->authorform->getName());
            $this->authorform->bind(
                    $request->getParameter($this->authorform->getName())
            );
            if ($this->authorform->isValid()) {
                $this->authorform->save();
            }
        }
    }

    public function executeTwitter(sfWebRequest $request) {
        
    }

}
